<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<title>コントロールパネル</title>
		<link rel="stylesheet" href="./assets/styles/default.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/ui-lightness/ui.all.css" type="text/css" />
		<script src="assets/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
		<script src="assets/scripts/jquery-ui-1.7.3.custom.min.js" type="text/javascript"></script>
		<script src="assets/scripts/ui/ui.dialog.js" type="text/javascript"></script>
		<script src="assets/scripts/menu.js" type="text/javascript"></script>
		<script src="assets/scripts/table.js" type="text/javascript"></script>
		<script type="text/javascript" src="./assets/scripts/editor.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.datepicker.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.core.js"></script>
		<script type="text/javascript" src="./assets/scripts/table.js" type="text/javascript"></script>
		<link rel="stylesheet" href="./assets/styles/cellgrid.css" type="text/css" />
		<style type="text/css">
		.manage{display:block}
		.cost{display:none}
		.benefit{display:none}
input,
.text{
	*font-family: "MS Pゴシック","ＭＳ Ｐゴシック","MS P Gothic";
	line-height:120%;
	height:25px;
	width:96%;
}
	.texthead,
	textarea {
		*font-family: "MS Pゴシック","ＭＳ Ｐゴシック","MS P Gothic";
		line-height:120%;
		height:25px;
		width:96%;
	}
	select{
		width:96%;
	}
		</style>
		<script type="text/javascript">
	    function rObj(map, saletickt) {
	        this.map = map;
	        this.saletickt = saletickt;
	    }
	 //   array("map" => $v["map"], "saletickt"=> $v["saletickt"], "exp_ins_flg"=>  $v["exp_ins_flg"] );
		var map_disp = new Array();
		{{ foreach from=$title_map key=kk item=vv name="member" }}
		map_disp["{{$kk}}"] = new rObj("{{$vv.map }}", "{{$vv.saletickt}}" );
		{{ /foreach }}
		var maptype = new Array();
		{{ foreach from=$aokimapsort key=kk item=vv name="member" }}
		maptype[{{$kk}}] = "{{$vv}}";
		{{ /foreach }}

		var g_p_nums = new Array();
		{{ foreach from=$pattern_nums key=kk item=vv name="member" }}
			g_p_nums["{{$vv.shop_cd}}_{{$vv.pattern_cd}}"] = {{$vv.nums}};
		{{ /foreach }}

		var sp_map =new Array();
		{{ foreach from=$shopmapno key=kk item=vv name="member" }}
		sp_map["{{$kk}}"] = [ '{{$vv.r}}', '{{$vv.i}}', '{{$vv.m4}}','{{$vv.m5}}','{{$vv.l1}}', '{{$vv.l2}}', '{{$vv.l3}}', '{{$vv.l4}}', '{{$vv.l5}}'  ];
		{{ /foreach }}
		$(function() {
			$('.message').fadeIn("slow");
			//*******************
			$("#disp_td").live('change',function(){
				set_disp_td($(this).val());
			});
			$(".titlebase").live('change',function(){
				var id = $(this).attr("id") ;
				var index = id.split("_")[1] * 1 ;

				sum_all(index);

				var shop_cd = $("#sp" + index).val() ;
				var vid = $(this).val();
				var shop_map = "";
				var shop_map_type = "";
				var isregyu = "";
				$("#mps_" + index).html("");
				$("#mpno_" + index).attr("value", "");
				$("#isirgyu_"  + index).attr("value", "");
				var mapflg = true;
				if (map_disp[vid]!=null) {
					isregyu = map_disp[vid].map;
					if (isregyu == 1) {
						shop_map = sp_map[shop_cd][0];
						shop_map_type = maptype[1];
					} else if (isregyu == 2) {
						shop_map = sp_map[shop_cd][1];
						shop_map_type = maptype[2];
					} else if (isregyu == 4) {
						shop_map = sp_map[shop_cd][2];
						shop_map_type = maptype[4];
					} else if (isregyu == 5) {
						shop_map = sp_map[shop_cd][3];
						shop_map_type = maptype[5];
					}

					if  ( shop_map == "" ) {
						alert("マップNOは存在しないので、選択できできません。");
						$(this).val("");
						mapflg =  false;
					}else {
						$("#mps_" + index).html( "( " +shop_map_type + "&nbsp;" + shop_map  + " )" ) ;
						$("#mpno_"  + index).attr("value", shop_map);
						$("#isirgyu_"  + index).attr("value", map_disp[vid].map);
					}
				}
				//子店舗
				if  ($(this).attr("ref") ) {
					var titlename  = "";
					var mpsdisp   = "";
					if (mapflg && shop_map) {
						titlename = $(this).find('option:selected').text();
						mpsdisp   =  "( " + shop_map_type + "&nbsp;" + shop_map  + " )"
					}
					var sub_title_class = $(this).attr("ref");
					var groupNo = sub_title_class.split("_")[1] ;

					$(".t_" + groupNo).each(function(){
						$(this).attr("value", vid);
					});
					$(".tm_" + groupNo).each(function(){
						$(this).attr("value", titlename);
					});
					$(".mps_" + groupNo).each(function(){
						$(this).html( mpsdisp ) ;
					});

					$(".mp_" + groupNo).each(function(){
						$(this).attr("value",shop_map);
					});

					$(".is_" + groupNo).each(function(){
						$(this).attr("value", isregyu);
					});


				}
				return "";
			});

			$(".spattern").live('change',function(){
				var val = $(this).val();
				var id = $(this).attr("id");
				var index = id.split("_")[2] * 1;
				theID = "n" + id;
				var nums = "";
				if (val == "" ) {
					$('#'+ theID ).val("");
				} else {
					nums = getPNums($('#fm [name^=shop_cd]').eq(index).attr("value"),val)
					$('#'+ theID ).val(nums);
				}
			});

			$(".celltext").live('change',function(){
				var id = $(this).attr("id");
				var index = id.split("_")[2] * 1;
				sum_all(index);
				//子店舗
					if  ( $(this).attr("ref") ) {
						var val = $(this).val();
						var group_class = $(this).attr("ref");

						$("." + group_class).each(function(){
							$(this).attr("value", val);
						});
					}
				});

			$('.btn_save').live('click',function(){
				if( confirm('更新してよろしいですか？') ){
					document.fm.target = "i_frame";
					document.fm.mode.value = 'input';
					document.fm.submit();
				}
			});

			$('a.tddel').live('click',function(){
				$('#rtr_' + $(this).attr("id") ).remove();
				$(this).closest('tr').remove();
			});

		});
		function checkTitle (index){
			var titleFlag = false;
			if  ( $("#tx_" +index).val() != "" ) {
				titleFlag = true;
			}
{{ foreach from=$cell_wsets key=ck item=cv name="csets" }}
 {{assign var="jj" value=$smarty.foreach.csets.index}}
 			if  ( $("#t{{$jj}}_" + index ).val() != "" ) {
				if (titleFlag) {
					return false;
				}
				titleFlag = true;
			}
{{ /foreach }}
			return true;
		}
	function getPNums(shopcd,patterncd) {
		var vid =  shopcd + "_" + patterncd;
		if (vid in g_p_nums) {
			return g_p_nums[vid];
		}
		return "";
	}

	function hpa() {
		$("#pop_cp").hide();
		ginnerdiv = false;
	}
	function spa(val, text) {
		hpa();

		$("#"+gpatt_id).attr("value", text);

		var id  = gpatt_id.replace("nm", "")
		$("#" + id).attr("value", val);
		var index = id.split("_")[2] * 1;
		theID = "n" + id;
		var nums = "";

		if (val != "" ) {
			nums = getPNums($('#fm [name^=shop_cd]').eq(index).attr("value"),val) ;
		}

		$('#'+ theID ).val(nums);

		if ( $("#"+gpatt_id).attr("ref")) {
			var groupNo = $("#"+gpatt_id).attr("ref");
			$(".pm"  + groupNo).each(function(){
				$(this).attr("value", text);
			});
			$(".p" + groupNo).each(function(){
				$(this).attr("value", val);
			});
		}
	}
	var gpatt_id = null;
	var ginnerdiv = false;
	$(function(){
		$('.pnm').focus(function(){
			disppattern( $(this), "#pop_tp");
		});

		$('.pnq').focus(function(){
			disppattern( $(this), "#pop_qp");
		});
		document.onclick=function(e){
			var e=e?e:window.event;
			var tar = e.srcElement||e.target;
			if (!ginnerdiv) {
				if ( ( $(tar).attr("class") != "pnm") && ( $(tar).attr("class") != "pnq") ){
					hpa();
				}
			}
		}
	    $("#pop_cp").live("mouseenter",function(){
	    	ginnerdiv = true;
	    });
	    $("#pop_cp").live("mouseleave",function(){
	    	ginnerdiv = false
	    });


	});
	function disppattern(obj, val) {
		$('#pop_cp').html($(val).html() )
		var offset =  obj.offset();
		gpatt_id   =  obj.attr("id");
		var top = offset.top + obj.height() + 5 ;
		var bottom = document.body.scrollTop+document.body.clientHeight;
		if  (top + 350 >bottom) {
			top = bottom - 350;
		}
		var left  = offset.left + obj.width() - 380 ;
		$('#pop_cp').css({
				'display':'block',
				'top': top +'px',
				'left':left+'px',
				'position':'absolute'
		});
	}
	function jumpl(val) {
		$('#rdiv').scrollLeft(val);
		//var txtop = $("#rdiv").offset().top;
		//$('#rdiv').scrollTo(txtop, 200 )
	}

	function reshow(idv) {
		//var txleft = $("#rdiv").offset().left;
		//alert(txleft);
		// $("#rdiv").offset({left:100});
		//$("#" + idv).css({ "left:" + txleft });
	}
	function dorscroll(){
		document.getElementById('rdiv').scrollLeft=this.scrollLeft;
	}
	var disp_css = 1;
	function set_disp_td(val) {
		var disp = new Array(4) ;
		disp[1] = ".manage";
		disp[2] = ".cost";
		disp[3] = ".benefit";
		var val_index = val * 1;
		for (i=1;i<=3;i++) {
			if  (i!=val_index) {
				$( disp[i] ).css("display", "none");
			}
		}
		$( disp[val_index] ).css("display", "block");
	}
	//サイズ単価
	var gssp =new Array();
	{{ foreach from=$data key=kk item=vv name="member" }}
 {{assign var="i" value=$smarty.foreach.member.index}}
 gssp[{{$i}}] =  [ {{$vv.b2}}, {{$vv.b3}}, {{$vv.b4}},{{$vv.ratio}} ];
	{{ /foreach }}

	function gNum(val){
		if (isNaN(val)){
			return 0;
		}else {
			return val * 1;
		}
	}

	///見込チラシ経費
	function sum_qrs(i){
		var b2 = gNum( $("#smpc_b2_"+ i).val() ) + gNum( $("#npc_b2_"+ i ).val() );
		var b3 = gNum( $("#smpc_b3_"+ i).val() ) + gNum( $("#npc_b3_"+ i ).val() );
		var b4 = gNum( $("#smpc_b4_"+ i).val() ) + gNum( $("#npc_b4_"+ i ).val() );

		{{ foreach from=$cell_wsets key=ck item=cv name="csets" }}
			 b2 = b2 +  gNum( $("#{{$cv.smpc_b2}}_"+ i).val() ) + gNum( $("#{{$cv.npc_b2}}_"+ i ).val() );
			 b3 = b3 +  gNum( $("#{{$cv.smpc_b3}}_"+ i).val() ) + gNum( $("#{{$cv.npc_b3}}_"+ i ).val() );
			 b4 = b4 +  gNum( $("#{{$cv.smpc_b4}}_"+ i).val() ) + gNum( $("#{{$cv.npc_b4}}_"+ i ).val() );
		{{ /foreach }}
		var suma = 0;

		if (b2 != 0) {
			//alert(b2)
			suma = b2 * gssp[i][0] * gssp[i][3];
		}
		if (b3 != 0) {
			suma = suma + b3* gssp[i][1] * gssp[i][3];
		}
		if (b4 != 0) {
			alert(b4)
			suma = suma + b4* gssp[i][2] * gssp[i][3];
		}
		return suma.toFixed(2);

	}
	function sum_row(i){
		//費用計算
		var area = $("#zac1_" + i ).html() ;
		if (!(area)) {
			area = 0;
		}
		//チラシ費用
		var qrs =  sum_qrs(i);
		$("#zqc1_" + i ).html(qrs);

		// 本年見込
		var nowyear = qrs*1 + area * 1;
		$("#zkc1_" + i ).html( nowyear );

		//計画
		var plane = $("#zkc2_" + i ).html() * 1;
		//前年
		var lastyear = $("#zkc3_" + i ).html() * 1;

		//計画差   本年見込 - 計画
		$("#zqc2_" + i ).html( nowyear - plane )
		//計画比   本年見込 / 計画
		if  ( plane != 0 ) {
			$("#zac2_" + i ).html( (100*nowyear / plane).toFixed(2) ) ;
		}
		//前年差   本年見込 - 前年
		$("#zqc3_" + i ).html( nowyear - lastyear )
		//前年比   本年見込 / 前年
		if  ( lastyear != 0 ) {
			$("#zac3_" + i ).html( (100*nowyear / lastyear).toFixed(2) );
		}
		//利益見込
		var nowqua   = $("#zkm1_" + i ).html() * 1;
		var planequa = $("#zkm2_" + i ).html() * 1;
		var lastqua  = $("#zkm3_" + i ).html() * 1;
		//利益本年
		$("#zkb1_" + i ).html( nowqua   - nowyear ) ;
		//利益計画
		$("#zkb2_" + i ).html( planequa - plane ) ;
		//利益前年
		$("#zkb3_" + i ).html( lastqua  - lastyear ) ;
	}
	//見込、計画、前年経費計算
	function sum_head(){
		//チラシ合計
		var su_qira = 0;
		$(".qira" ).each(function(){
			su_qira = su_qira + $(this).html() * 1;
		});
		$("#su_qira").html( su_qira );
		//地域広告 合計
		var su_qiar = 0;
		$(".qiar" ).each(function(){
			su_qiar = su_qiar + $(this).html() * 1;
		});
		$("#su_area").html( su_qiar );
		//見込計
		var su_all = su_qira +su_qiar * 1;
		$("#su_all").html( su_all );

		//計画計
		var su_psum = 0;
		$(".plco" ).each(function(){
			su_psum = su_psum + $(this).html() * 1;
		});
		$("#su_psum").html(su_psum)
		//計画差異
		//var su_psum =  $("#su_psum").html() * 1
		$("#su_pdec").html( su_all - su_psum );

		//計画比
		if (su_psum != 0) {
			$("#su_pper").html( ( 100* su_all / su_psum).toFixed(2) );
		} else {
			$("#su_pper").html( 0 );
		}
		//前年計
		var su_lsum = 0;
		$(".lsco" ).each(function(){
			su_lsum = su_lsum + $(this).html() * 1;
		});
		$("#su_lsum").html(su_lsum)
		//前年差異
		//var su_lsum =  $("#su_lsum").html() * 1
		$("#su_ldec").html( su_all - su_lsum );

		//前年比
		if (su_lsum != 0) {
			$("#su_lper").html( ( 100* su_all / su_lsum).toFixed(2) );
		}else{
			$("#su_lper").html( 0 );
		}
	}
	function sum_all(i){
		 sum_row(i);
		 sum_head();
	}
	function load_sum_all(){

		var shops   = document.getElementsByName( 'shop_cd[]');
		$.each(shops, function(i,val){
			sum_row(i);
		});

		 sum_head();
	}
	//費用計算
	window.onload = load_sum_all ;
		</script>
	</head>
<body id="">
{{ $menu }}
{{ $logout }}
		<div id="container"><div class="wrapper">
			<h2>印刷手配管理</h2>
			<ul class="submenu clearfix">
				<li><a href="tmoncell_index.php">月間.セール明細情報一覧</a></li>
				{{if !$isG23 }}<li><a href="tmoncell_form.php">月間.セール明細情報登録</a></li>{{ /if }}
				<li>月間.セール明細情報更新</a></li>
				{{if !$isG23 }}<li><a href="tmoncellprn_index.php">印刷部数明細</a></li>{{ /if }}
				<li><a href="tmoncellshop_index.php">店舗実施一覧表</a></li>
			</ul>
			<h3>月間.セール明細情報更{{ if $phase == 'complete' }}完了{{ /if }}</h3>
{{ if $phase == 'input' }}
<p class="message">内容</p>
<form name="fm" id = "fm" action="tmoncell_updatesubmit.php" method="post">
<p>
	<b>週名 ：
	{{ $forms.year4 }}年度 &nbsp; {{ $forms.week_cd }}週目 {{ if $forms.week_seq  }}  &nbsp; {{ $forms.week_seq }}回{{ /if }}
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;配布日 : {{ $forms.flier_date }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	 ステータス : {{ $forms.status }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;最終更新日時 :{{ $forms.u_time|date_format:"%Y/%m/%d %H:%M" }}</b>
	<input type="hidden" name="matrix_cd"  value="{{ $forms.matrix_cd }}" />
	<input type="hidden" name="aja_cd"     value="{{ $forms.aja_cd }}" />
	<input type="hidden" name="week_cd"    value="{{ $forms.week_cd }}" />
	<input type="hidden" name="year4"      value="{{ $forms.year4 }}" />
	<input type="hidden" name="week_seq"   value="{{ $forms.week_seq}}" />
	<input type="hidden" name="flier_date" value="{{ $forms.status}}" />
	<input type="hidden" name="status"     value="{{ $forms.flier_date}}" />
	<input type="hidden" name="u_time"     value="{{ $forms.u_time }}" />
	{{if (!empty($edit_msg)) }}<div  class="errmsg">{{ $edit_msg}}&nbsp;&nbsp; </div> {{ /if }}<div  id="submsgid" class="errmsg">{{ $errmsg}} </div>
</p>
 <table class="formTable" style="width:100%" >
 <tr><th colspan='3'>見込</th><th colspan='3'>計画</th><th colspan='3'>前年比</th></tr>
 <tr><td align="center">チラシ</td><td align="center">地域広告</td><td align="center">見込計</td>
 <td align="center">計画計</td><td align="center">計画差異</td><td align="center">計画比</td>
 <td align="center">前年計</td><td align="center">前年差異</td><td align="center">前年比</td></tr>
 <tr><td align="right"><span id="su_qira">0</span></td><td align="right"><span id="su_area"></span></td><td align="right"><span id="su_all">0</span></td>
 <td align="right"><span id="su_psum">0</span></td><td align="right"><span id="su_pdec">0</span></td><td align="right"><span id="su_pper">0</span></td>
 <td align="right"><span id="su_lsum">0</span></td><td align="right"><span id="su_ldec">0</span></td><td align="right"><span id="su_lper">0</span></td></tr>
 </table><br>
 <div class="all_div" >
 <table style="table-layout:fixed;word-wrap:break-word;word-break:break-all;" >
 <tr>
 <td style="width:180px;height:80px;text-align:center"><select  id="disp_td" name="disp_td">{{ html_options   options=$disp_td  }}</select></td>
 </tr>
 </table>
 <div>
 <div class="l_head_div" id ="lhdiv">
 <table class="formTable" id = "head_tab_l" style="table-layout:fixed;word-wrap:break-word;word-break:break-all;" >
 <tr><th style="width:23px;height:80px">合<br/>同</th>
 <th style="width:130px;height:80px">店舗コード<br/>店舗名<br/>AJAエリア </th>
  <th style="width:18px"></th>
 <th style="width:60px">見込</th>
  <th style="width:18px"></th>
 <th style="width:60px">計画</th>
  <th style="width:18px"></th>
 <th style="width:60px">前年</th>
 <th style="width:18px"></th>
 <th style="width:70px">前年<br>売上高<br>実績</th>
 </tr>
 </table>
 </div>
 <div class="r_head_div" id ="rhdiv" onscroll="document.getElementById('rdiv').scrollLeft=this.scrollLeft;">
 <table class="formTable" id = "head_tab_r"  style="width:{{$fw.tabw}}px">
<tr style="height:26px;">
 <th style="height:26px;" colspan="{{$fw.colnums}}" > 通常チラシ&nbsp;<a href="javascript:jumpl({{$fw.cw}});"> >> </a></th>
{{ foreach from=$cell_losets key=ck item=cv name="csets" }}
<th colspan="6" ><a href="javascript:jumpl({{$cv.tol}});"> << </a>&nbsp;&nbsp; {{$cv.name}}{{if $ck != 5 }} &nbsp;&nbsp;<a href="javascript:jumpl({{$cv.tor}});"> >> </a>{{/if}}</th>
{{ /foreach }}
 </tr>
 <tr style="height:26px;">
 <th rowspan="2" style="width:{{$fw.title}}px;">セールタイトル(マップNo)<br>[]内は前年</th>
 <th rowspan="2"  style="width:{{$fw.size}}px;"></th>
 <th colspan="3" style="height:26px;">前年</th>
 <th colspan="3" style="height:26px;">本年</th>
{{ foreach from=$cell_wsets key=ck item=cv name="csets" }}
 <th colspan="3" style="height:26px;">{{$cv.name}}</th>
{{ /foreach }}
{{ foreach from=$cell_losets key=ck item=cv name="csets" }}
 <th rowspan="2" style="width:{{$fw.title}}px;">セールタイトル(マップNo)<br>[]内は前年</th> <th rowspan="2" style="width:{{$fw.size}}px;"></th>
 <th colspan="2" style="height:26px;">前年</th><th colspan="2">本年</th>
{{ /foreach }}
 </tr>
 <tr  style="height:26px;">
 <th style="height:26px;width:{{$fw.sample}}px;">見本</th>
 <th style="height:26px;width:{{$fw.num}}px;">部数</th>
 <th style="width:{{$fw.pattern}}px;">パターン</th>
 <th style="height:26px;width:{{$fw.sample}}px;">見本</th>
 <th style="width:{{$fw.num}}px;">部数</th>
 <th style="width:{{$fw.pattern}}px;">パターン</th>
{{ foreach from=$cell_wsets key=ck item=cv name="csets" }}
 <th style="height:26px;width:{{$fw.sample}}px;">見本</th>
 <th style="width:{{$fw.num}}px;">部数</th>
 <th style="width:{{$fw.pattern}}px;">パターン</th>
{{ /foreach }}
 {{ foreach from=$cell_losets key=ck item=cv name="csets" }}
<th style="width:{{$fw.num}}px;height:26px;">部数</th><th style="width:{{$fw.pattern}}px;">パターン</th>
<th style="width:{{$fw.num}}px;">部数</th><th style="width:{{$fw.pattern}}px;">パターン</th>
{{ /foreach }}
 </tr>
	</table>
 </div>
 <div class="l_div" id="ldiv" onscroll="document.getElementById('rdiv').scrollTop=this.scrollTop;">
 <table class="formTable" id = "1_tab_l" style="table-layout:fixed;word-wrap:break-word;word-break:break-all;" >
 <tr style="height:1px;">
 <th style="width:23px;height:1px"></th>
 <th style="width:130px;height:1px"></th>
 <th style="width:18px"></th>
 <th style="width:60px"></th>
 <th style="width:18px"></th>
 <th style="width:60px"></th>
 <th style="width:18px"></th>
 <th style="width:60px"></th>
 <th style="width:18px"></th>
 <th style="width:70px"></th>
 </tr>
 {{ foreach from=$data key=kk item=vv name="member" }}
 {{assign var="i" value=$smarty.foreach.member.index}}
  <tr>
  <td rowspan=3><input type="text" name="congruent_ins[]" class="dtext" value="{{ $vv.congruent_ins }}" readonly/></td>
	<td rowspan=3>
	<input type="text" id="sp{{$i}}"  name="shop_cd[]"     class="dtext" value="{{ $vv.shop_cd }}" readonly/></br>
	<input type="text" name="shop_name[]"   class="dtext" value="{{ $vv.shop_name }}" readonly/></br>
	({{ $vv.user_name }})<!-- <br>({{ $vv.zuser_name }}) --><br>
	{{ $vv.sale }}
	</td>
	<td align=center>計</td><td> <span id="zkm1_{{$i}}" class = "manage">{{ $vv.now_qua }}</span><span id="zkc1_{{$i}}" class = "cost"></span><span  id="zkb1_{{$i}}" class="benefit">0</span> </td>
	<td align=center>計</td><td> <span id="zkm2_{{$i}}" class = "manage">{{ $vv.plane_qua }}</span><span id="zkc2_{{$i}}" class = "plco cost">{{$vv.plane_cost}}</span><span  id="zkb2_{{$i}}" class="benefit">0</span> </td>
	<td align=center>計</td><td> <span id="zkm3_{{$i}}" class = "manage">{{ $vv.last_qua }}</span><span id="zkc3_{{$i}}" class = "lsco cost">{{$vv.last_cost}}</span><span  id="zkb3_{{$i}}" class="benefit">0</span> </td>
	<td align=center>土</td><td><input type="text"  name="ly_sale6[]"   class="dtext" value="{{ $vv.lyear_sale6 }}" readonly/></td>
	</tr><tr>
	<td align=center>チ</td><td> <span id="zqm1_{{$i}}" class = "manage"></span><span id="zqc1_{{$i}}" class = "qira cost"></span><span id="zqb1_{{$i}}" class="benefit"></span> </td>
	<td align=center>差</td><td> <span id="zqm2_{{$i}}" class = "manage"></span><span id="zqc2_{{$i}}" class = "cost"></span><span id="zqb2_{{$i}}" class="benefit"></span> </td>
	<td align=center>差</td><td> <span id="zqm3_{{$i}}" class = "manage"></span><span id="zqc3_{{$i}}" class = "cost"></span><span id="zqb3_{{$i}}" class="benefit"></span> </td>
	<td align=center>日</td><td><input type="text"  name="ly_sale7[]"   class="dtext" value="{{ $vv.lyear_sale7 }}" readonly/></td>
	</tr><tr>
	<td align=center>地</td><td> <span id="zam1_{{$i}}" class = "manage"></span><span  id="zac1_{{$i}}" class = "qiar cost">{{$vv.loc_cost}}</span><span  id="zab1_{{$i}}" class="benefit"></span> </td>
	<td align=center>比</td><td> <span id="zam2_{{$i}}" class = "manage"></span><span  id="zac2_{{$i}}" class = "cost"></span><span  id="zab2_{{$i}}" class="benefit"></span> </td>
	<td align=center>比</td><td> <span id="zam3_{{$i}}" class = "manage"></span><span  id="zac3_{{$i}}" class = "cost"></span><span  id="zab3_{{$i}}" class="benefit"></span> </td>
	<td align=center>計</td><td><input type="text"  name="ly_sale[]"   class="dtext" value="{{ $vv.lyear_sale }}" readonly/></td>
	</tr>
{{ /foreach }}
 </table>
 </div>
<div class="r_div" id="rdiv" onscroll="document.getElementById('rhdiv').scrollLeft=this.scrollLeft;document.getElementById('ldiv').scrollTop=this.scrollTop;hpa();">
	<table class="formTable" id = "1_tab_r"  style="table-layout:fixed;word-wrap:break-word;word-break:break-all;width:{{$fw.tabw}}px">
	<tr style="height:1px;">
		<th style="height:1px;width:{{$fw.title}}px;"></th>
		<th style="width:{{$fw.size}}px;"></th>
		<th style="width:{{$fw.sample}}px;"></th><th style="width:{{$fw.num}}px;"></th><th style="width:{{$fw.pattern}}px;"></th>
		<th style="width:{{$fw.sample}}px;"></th><th style="width:{{$fw.num}}px;"></th><th style="width:{{$fw.pattern}}px;"></th>
{{ foreach from=$cell_wsets key=ck item=cv name="csets" }}
		<th style="width:{{$fw.sample}}px;"></th><th style="width:{{$fw.num}}px;"></th><th style="width:{{$fw.pattern}}px;"></th>
{{ /foreach }}
{{ foreach from=$cell_losets key=ck item=cv name="csets" }}
		<th style="width:{{$fw.title}}px;"></th><th style="width:{{$fw.size}}px;">
		</th><th style="width:{{$fw.num}}px;"></th><th style="width:{{$fw.pattern}}px;"></th> <th style="width:{{$fw.num}}px;"></th><th style="width:{{$fw.pattern}}px;"></th>
{{ /foreach }}
		</tr>
{{ foreach from=$data key=kk item=vv name="member" }}
 {{assign var="i" value=$smarty.foreach.member.index}}
	<tr>
	<td rowspan='3'>
	<!--<input type="text"  name="ltitle_cd[]"   class="dtext" value="{{ $vv.ltitle_cd }}" readonly/> -->
	{{ $vv.ltitle_cd }}<br>
{{if $vv.mark != '9' }}
<select  id="tx_{{$i}}" name="title_cd[]" class="titlebase"  {{if $vv.mark == '1' }} ref="t_{{$vv.group_no}}" {{/if}} > {{ html_options   options=$title selected=$vv.title_cd  }}</select>
{{else}}
<input type="hidden"  name="title_cd[]"  class="t_{{$vv.group_no}}" value="{{ $vv.title_cd }}" />
<input type="text"  name="title_nm[]"  class="dtext tm_{{$vv.group_no}}"  {{if $vv.title_cd }} value="{{ $title[$vv.title_cd] }} {{/if}}" readonly/>
{{/if}}<br>
  <span id="mps_{{$i}}" {{if $vv.mark == '9' }} class="mps_{{$vv.group_no}}" {{ /if }} > {{ if $vv.mpno  }} ( {{ $vv.mp }} {{ $vv.isirgyu }}&nbsp; {{ $vv.mpno }} ){{ /if }} </span>
	<input type="hidden" id="mpno_{{$i}}"  name="mpno[]" value="{{ $vv.mpno }}"  {{if $vv.mark == '9' }} class="mp_{{$vv.group_no}}"	{{ /if }}/>
	<input type="hidden" id="isirgyu_{{$i}}"  name="isirgyu[]" value="{{ $vv.isirgyu }}" {{if $vv.mark == '9' }} class="is_{{$vv.group_no}}"	{{ /if }} />
	<!--<br>{{ $vv.vtype }}版下タイプ"  版下タイプ -->
	</td>
	<td align=center>B2</td>
	<td><input type="text"  name="lsmpc_b2[]"  class="dtext" value="{{ $vv.lsmpc_b2}}" readonly/></td>
	<td><input type="text"  name="lnpc_b2[]"   class="dtext" value="{{ $vv.lnpc_b2}}"  readonly/></td>
	<td><input type="text"  name="lpc_b2[]"    class="dtext" value="{{ $vv.lpc_b2}}"   readonly/></td>

	<td><input type="text"  id="smpc_b2_{{$i}}"   name="smpc_b2[]"  class="{{if $vv.mark == '9' }}dtext mc2_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="mc2_{{$vv.group_no}}" {{/if}} value="{{ $vv.smpc_b2}}" /></td>
	<td><input type="text"  id="npc_b2_{{$i}}"    name="npc_b2[]"   class="{{if $vv.mark == '9' }}dtext nc2_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="nc2_{{$vv.group_no}}" {{/if}}  value="{{ $vv.npc_b2}}" /></td>
	<td><input type="text"  id="nmpc_b2_{{$i}}"    name="nmpc_b2[]"  {{if $vv.mark == '1' }} ref="2_{{$vv.group_no}}" {{/if}} {{if $vv.mark == '9' }} class="pm2_{{$vv.group_no}} dtext" {{else}} class="pnm" {{/if}}  value="{{ $pattern[$vv.pc_b2] }}" readonly/>
	<input type="hidden"  id="pc_b2_{{$i}}"  name="pc_b2[]"   value="{{ $vv.pc_b2 }}"  {{if $vv.mark == '9' }} class="p2_{{$vv.group_no}}" {{/if}} /></td>
{{ foreach from=$cell_wsets key=ck item=cv name="csets" }}
 {{assign var="jj" value=$smarty.foreach.csets.index}}
		<td><input type="text"  id="{{$cv.smpc_b2}}_{{$i}}" name="{{$cv.smpc_b2}}[]"   class="{{if $vv.mark == '9' }}dtext wmc2_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="wmc2_{{$vv.group_no}}" {{/if}} value="{{ $vv[$cv.smpc_b2]}}" /></td>
		<td><input type="text"  id="{{$cv.npc_b2}}_{{$i}}"  name="{{$cv.npc_b2}}[]"   class="{{if $vv.mark == '9' }}dtext wnc2_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="wnc2_{{$vv.group_no}}" {{/if}} value="{{ $vv[$cv.npc_b2]}}" /></td>
		 {{ assign var = "patt_cd" value = $vv[$cv.pc_b2] }}
		<td><input type="text"    id="nm{{$cv.pc_b2}}_{{$i}}" name="nm{{$cv.pc_b2}}[]"    {{if $vv.mark == '1' }} ref="w2_{{$vv.group_no}}" {{/if}} {{if $vv.mark == '9' }} class="pmw2_{{$vv.group_no}} dtext" {{else}} class="pnm" {{/if}} value="{{ $pattern[$patt_cd]  }}" readonly/>
		<input type="hidden"  id="{{$cv.pc_b2}}_{{$i}}"  name="{{$cv.pc_b2}}[]"  value="{{ $patt_cd }}" {{if $vv.mark == '9' }} class="pw2_{{$vv.group_no}}" {{/if}} /></td>
{{ /foreach }}
{{ foreach from=$cell_losets key=ck item=cv name="csets" }}
 {{assign var="jj" value=$smarty.foreach.csets.index}}
		<td rowspan='3'>{{ $vv[$cv.ltitle_cd] }}<br> {{$vv[$cv.title_cd]}}{{ if $vv[$cv.mpno]  }}</br> ( {{ $vv[$cv.mp] }}  {{ $vv[$cv.isirgyu] }}&nbsp; {{ $vv[$cv.mpno] }} ){{ /if }}</td>
		<td align=center>B2</td>
		<td><input type="text"  name="{{$cv.lnpc_b2}}[]"   class="dtext" value="{{ $vv[$cv.lnpc_b2] }}" readonly /></td>
		<td><input type="text"  name="{{$cv.lpc_b2}}[]"    class="dtext" value="{{ $vv[$cv.lpc_b2] }}"  readonly /></td>
		<td>{{ $vv[$cv.npc_b2]}}</td>
		 {{ assign var = "patt_cd" value = $vv[$cv.pc_b2] }}
		 <td>{{ $areapattern[$patt_cd] }}</td>
{{ /foreach }}
	</tr><tr>
		<td align=center>B3</td>
		<td><input type="text"  name="lsmpc_b3[]"  class="dtext" value="{{ $vv.lsmpc_b3}}" readonly/></td>
		<td><input type="text"  name="lnpc_b3[]"   class="dtext" value="{{ $vv.lnpc_b3}}" readonly/></td>
		<td><input type="text"  name="lpc_b3[]"    class="dtext" value="{{ $vv.lpc_b3}}" readonly/></td>
		<td><input type="text"  id="smpc_b3_{{$i}}" name="smpc_b3[]"  class="{{if $vv.mark == '9' }}dtext mc3_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="mc3_{{$vv.group_no}}" {{/if}} value="{{ $vv.smpc_b3}}" /></td>
		<td><input type="text"  id="npc_b3_{{$i}}" name="npc_b3[]"   class="{{if $vv.mark == '9' }}dtext nc3_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="nc3_{{$vv.group_no}}" {{/if}} value="{{ $vv.npc_b3}}" /></td>
		<td><input type="text"  id="nmpc_b3_{{$i}}" name="nmpc_b3[]"    {{if $vv.mark == '1' }} ref="3_{{$vv.group_no}}" {{/if}} {{if $vv.mark == '9' }} class="pm3_{{$vv.group_no}} dtext" {{else}} class="pnm" {{/if}} value="{{ $pattern[$vv.pc_b3] }}" readonly/>
		<input type="hidden"  id="pc_b3_{{$i}}"  name="pc_b3[]"   value="{{ $vv.pc_b3 }}"  {{if $vv.mark == '9' }} class="p3_{{$vv.group_no}}" {{/if}}/></td>
 {{ foreach from=$cell_wsets key=ck item=cv name="csets" }}
		<!--<td align=center>B3</td>-->
		<td><input type="text"  id="{{$cv.smpc_b3}}_{{$i}}" name="{{$cv.smpc_b3}}[]"  class="{{if $vv.mark == '9' }}dtext wmc3_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="wmc3_{{$vv.group_no}}" {{/if}} value="{{ $vv[$cv.smpc_b3]}}" /></td>
		<td><input type="text"  id="{{$cv.npc_b3}}_{{$i}}" name="{{$cv.npc_b3}}[]"    class="{{if $vv.mark == '9' }}dtext wnc3_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="wnc3_{{$vv.group_no}}" {{/if}} value="{{ $vv[$cv.npc_b3]}}" /></td>
		 {{ assign var = "patt_cd" value = $vv[$cv.pc_b3] }}
		<td><input type="text"    id="nm{{$cv.pc_b3}}_{{$i}}" name="nm{{$cv.pc_b3}}[]"    {{if $vv.mark == '1' }} ref="w3_{{$vv.group_no}}" {{/if}} {{if $vv.mark == '9' }} class="pmw3_{{$vv.group_no}} dtext" {{else}} class="pnm" {{/if}} value="{{ $pattern[$patt_cd]  }}" readonly/>
		<input type="hidden"  id="{{$cv.pc_b3}}_{{$i}}"  name="{{$cv.pc_b3}}[]"  value="{{ $patt_cd }}" {{if $vv.mark == '9' }} class="pw3_{{$vv.group_no}}" {{/if}}/></td>
 {{ /foreach }}
{{ foreach from=$cell_losets key=ck item=cv name="csets" }}
		<td align=center>B3</td>
		<td><input type="text"  name="{{$cv.lnpc_b3}}[]"   class="dtext" value="{{ $vv[$cv.lnpc_b3] }}" readonly /></td>
		<td><input type="text"  name="{{$cv.lpc_b3}}[]"    class="dtext" value="{{ $vv[$cv.lpc_b3] }}"  readonly /></td>
		<td>{{ $vv[$cv.npc_b3] }}</td>
		 {{ assign var = "patt_cd" value = $vv[$cv.pc_b3] }}
		<td>{{ $areapattern[$patt_cd]  }}</td>
{{ /foreach }}
	</tr><tr>
		<td align=center>B4</td>
		<td><input type="text"  name="lsmpc_b4[]"   class="dtext" value="{{ $vv.lsmpc_b4 }}" readonly/></td>
		<td><input type="text"  name="lnpc_b4[]"   class="dtext" value="{{ $vv.lnpc_b4 }}" readonly/></td>
		<td><input type="text"  name="lpc_b4[]"   class="dtext" value="{{ $vv.lpc_b4 }}" readonly/></td>
		<td><input type="text"  id="smpc_b4_{{$i}}" name="smpc_b4[]"   class="{{if $vv.mark == '9' }}dtext mc4_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="mc4_{{$vv.group_no}}" {{/if}} value="{{ $vv.smpc_b4 }}" /></td>
		<td><input type="text"  id="npc_b4_{{$i}}" name="npc_b4[]"   class="{{if $vv.mark == '9' }}dtext nc4_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="nc4_{{$vv.group_no}}" {{/if}} value="{{ $vv.npc_b4 }}" /></td>
		<td><input type="text"  id="nmpc_b4_{{$i}}" name="nmpc_b4[]"    {{if $vv.mark == '1' }} ref="4_{{$vv.group_no}}" {{/if}} {{if $vv.mark == '9' }} class="pm4_{{$vv.group_no}} dtext" {{else}} class="pnm" {{/if}} value="{{ $pattern[$vv.pc_b4] }}" />
		<input type="hidden"  id="pc_b4_{{$i}}"  name="pc_b4[]"   value="{{ $vv.pc_b4 }}" {{if $vv.mark == '9' }} class="p4_{{$vv.group_no}}" {{/if}}/></td>
 {{ foreach from=$cell_wsets key=ck item=cv name="csets" }}
		<!-- <td align=center>B4</td> -->
		<td><input type="text"  id="{{$cv.smpc_b4}}_{{$i}}" name="{{$cv.smpc_b4}}[]"   class="{{if $vv.mark == '9' }}dtext wmc4_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="wmc4_{{$vv.group_no}}" {{/if}} value="{{ $vv[$cv.smpc_b4]}}" /></td>
		<td><input type="text"  id="{{$cv.npc_b4}}_{{$i}}" name="{{$cv.npc_b4}}[]"  class="{{if $vv.mark == '9' }}dtext wnc4_{{$vv.group_no}}{{else}}celltext{{ /if }}" {{if $vv.mark == '1' }} ref="wnc4_{{$vv.group_no}}" {{/if}} value="{{ $vv[$cv.npc_b4]}}" /></td>
		 {{ assign var = "patt_cd" value = $vv[$cv.pc_b4] }}
		<td><input type="text"    id="nm{{$cv.pc_b4}}_{{$i}}" name="nm{{$cv.pc_b4}}[]"    {{if $vv.mark == '1' }} ref="w4_{{$vv.group_no}}" {{/if}} {{if $vv.mark == '9' }} class="pmw4_{{$vv.group_no}} dtext" {{else}} class="pnm" {{/if}} value="{{ $pattern[$patt_cd]  }}" readonly/>
		<input type="hidden"  id="{{$cv.pc_b4}}_{{$i}}"  name="{{$cv.pc_b4}}[]"  value="{{ $patt_cd }}" {{if $vv.mark == '9' }} class="pw4_{{$vv.group_no}}" {{/if}}/></td>
 {{ /foreach }}
{{ foreach from=$cell_losets key=ck item=cv name="csets" }}
		<td align=center>B4</td>
		<td><input type="text"  name="{{$cv.lnpc_b4}}[]"   class="dtext" value="{{ $vv[$cv.lnpc_b4] }}" readonly /></td>
		<td><input type="text"  name="{{$cv.lpc_b4}}[]"    class="dtext" value="{{ $vv[$cv.lpc_b4] }}"  readonly /></td>
		<td>{{ $vv[$cv.npc_b4]}}</td>
		 {{ assign var = "patt_cd" value = $vv[$cv.pc_b4] }}
		<td>{{ $areapattern[$patt_cd] }}</td>
{{ /foreach }}
	</tr>
{{ /foreach }}
	</table>
</div>
<div class = "all_div">
	<p  class="button" >
		<button type="button" class="btn_save"  class="submit btnleft"><span>更新</span></button>
	</p>
	<input type="hidden" name="mode" value="" />
</div>
</form>
{{ /if }}

{{ if $phase == 'complete' }}
	<p class="message">{{ $message }}</p>
	<ul>
		<li>>> <a href="tmoncell_index.php?hist=2">一覧ページに戻る</a></li>
		<li>>> <a href="tmoncell_formf.php?mm={{ $forms.map_no }}&ww={{ $forms.matrix_cd }}">更新</a></li>
	</ul>
{{ /if }}
		</div>
		</div>
 <div id="pop_cp" style = "width:380px; height:300px;background:#eeeecc;  overflow-y:scroll;display:none" > </div>
   <div id="pop_tp" style = "display:none" >
 <table width="98%" border="0" cellspacing="2" cellpadding="0" style="font-size:12px; line-height:17px;">
  <tr><td align="right" colspan=4><button type="button" onclick="javascript:spa('','')" ><span>クリア</span></button>&nbsp;&nbsp;</td></tr>
 {{ foreach from=$allpattern key=k item=v name="cs" }}
 {{ if  ($k == 1) ||  ($k == 4) ||  ($k == 5)   }}
 <tr><td align="left"><b>{{$patternflags[$k]}}</b></td></tr>
 <tr>
	 {{ foreach from=$v key=pk item=pv name="csets" }}
	 <td align="left">
	  <a href="javascript:void(0)" onclick="javascript:spa('{{$pk}}','{{$pv}}')" > {{$pv}} </a>
	   </td>
	    {{if $smarty.foreach.csets.index % 4 == 3}}</tr><tr>{{/if}}
	 {{ /foreach }}
  {{ /if }}
 {{ /foreach }}
 </table>
 </div>
 <!--
  <div id="pop_qp"  style = "display:none" >
 <table width="98%" border="0" cellspacing="2" cellpadding="0" style="font-size:12px; line-height:17px;">
  <tr><td align="right" colspan=4><button type="button" onclick="javascript:spa('','')" ><span>クリア</span></button>&nbsp;&nbsp;</td></tr>
 {{ foreach from=$allpattern key=k item=v name="cs" }}
 {{ if  ($k == 2) ||  ($k == 3) ||  ($k == 4)   }}
	 <tr><td align="left"><b>{{$patternflags[$k]}}</b></td></tr>
	 <tr>
	 {{ foreach from=$v key=pk item=pv name="csets" }}
	 	<td align="left">
	  <a href="javascript:void(0)" onclick="javascript:spa('{{$pk}}','{{$pv}}')" > {{$pv}} </a>
	   </td>
	    {{if $smarty.foreach.csets.index % 4 == 3}}</tr><tr>{{/if}}
	 {{ /foreach }}
  {{ /if }}
 {{ /foreach }}
 </table>
 </div>
 -->
 <iframe id='i_frame' name='i_frame' width='800px' height='400px' ></iframe>
<!-- width='1px' height='1px' style='display:none'  width='800px' height='400px'-->
<div class = "all_div" >{{ $footer }}</div>
	</body>
</html>